﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/**
 * 入力エラーエクセプション
 */
namespace Kaidou.Util
{
    public class InputErrorException
    {
        private List<ErrorCode> error = null;
        private System.Resources.ResourceManager rm;

        public InputErrorException(System.Resources.ResourceManager rm)
        {
            error = new List<ErrorCode>();
            this.rm = rm;
        }

        public void addErrorCode(ErrorCode ec)
        {
            ErrorCode[] ecs=error.ToArray();
            for (int i = 0; i < ecs.Length;i++ )
            {
                if (ecs[i].getErrorCode().Equals(ec.getErrorCode()))
                {
                    return;
                }
            }
            if (ec == null) return;
            error.Add(ec);
        }

        public void addErrorCode(string errorcode)
        {
            ErrorCode ec = new ErrorCode(errorcode, rm.GetString(errorcode).ToString());
            addErrorCode(ec);
        }

        public List<ErrorCode> getErrors()
        {
            return this.error;
        }

        public List<string> getErrorMessages()
        {
            List<string> list = new List<string>();
            for (int i = 0; i < error.Count;i++ )
            {
                string message=this.error.ElementAt(i).getErrorMessage();
                list.Add(message);
            }
            return list;
        }
    }
}
